package cn.wolfcode.restful.controller;

import cn.wolfcode.restful.domain.Employee;
import cn.wolfcode.restful.util.JsonResult;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;


@RestController
@RequestMapping("employees")
public class EmployeeController {
    //增
    @PostMapping
    public Employee save(Employee employee){
        return employee;
    }
    //删
    @DeleteMapping("{id}")
    public JsonResult delete(@PathVariable int id){
        return JsonResult.success(id);
    }
    //改
   @PutMapping
    public Employee update(Employee employee){
        return employee;
    }
    //查所有
    @GetMapping
    public List<Employee> queryAll(){
        return  Arrays.asList(new Employee(1,"zz",8),new Employee(2,"hh",50));
    }
    //查单个
    @GetMapping("{id}")
    public Employee queryOne(@PathVariable int id){
        return new Employee(id,"zz",8);
    }
}
